<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""DTD/xhtml1-strict.dtd">
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/c.tld" prefix="c"%>
<%@taglib uri="/WEB-INF/fmt.tld" prefix="fmt"%>
<%@taglib uri="/WEB-INF/fn.tld" prefix="fn"%>
<%@taglib uri="/WEB-INF/el.tld" prefix="el"%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<c:import url="/includes/css_inc.jsp"/>
		<c:import url="/includes/js_inc.jsp"/>
		<script>
			$(function(){
	        	var result = "";
				$("#btnSearch").button({
		            icons: {
		                primary: "ui-icon-search"
		            }
		        }).click(function(){
					if(validateEmpty()){
						result = dateDiff($("#startDateFilter").val(), $("#endDateFilter").val(),"/");
			        	if (!result && $("#startDateFilter").val() != "" && $("#endDateFilter").val() != "") {
			        		alert("วันเริ่มต้นต้องน้อยกว่าวันสิ้นสุดกรุณาระบุใหม่");
			        		$("#endDateFilter").val("");
							return false;
			        	} else {
							$("#searchForm").submit();
						}
					} else {
						return false;
					}
		        });
				/* $("#btnExport").button({
		            icons: {
		                primary: "ui-icon-arrowthickstop-1-s"
		            }
				}).click(function(){
					if(validateEmpty()){
						result = dateDiff($("#startDate").val(), $("#endDate").val(),"/");
			        	if (!result) {
			        		alert("วันเริ่มต้นมากกว่าวันสิ้นสุดกรุณาระบุใหม่");
			        		$("#endDate").val("");
							return false;
			        	} else {
			        		window.location='${pageContext.request.contextPath}/acc6?app=ACC60401&job=export&budgetYear='+$("#budgetYear").val()+'&provinceId='+$("#provinceId").val()+"&startDate="+$("#startDate").val()+"&endDate="+$("#endDate").val()+"&type="+$("#type").val()+"&allocateYear="+$("#allocateYear").val();
			        	}
					}	
				}); */
				
				$("#budgetYearFilter").change(function(){
					if ($("#budgetYearFilter").val() != "") {
						$("#startDateFilter").val("01/10/"+($("#budgetYearFilter").val()-1));
					}else {
						$("#startDateFilter").val("");
					}
				});
		        thaiDatepicker("startDateFilter","#","1");
		        thaiDatepicker("endDateFilter","#","1");
			});
		</script>
	</head>
	<body>
		<c:import url="/apps/msg.jsp"/>
		<form class="acc67-form" name="searchForm" id="searchForm" action="${pageContext.request.contextPath}/acc6" method="post"  target = "_blank">
		<input type="hidden" name="app" id="app" value="ACC6REPORT"/>
		<input type="hidden" name="job" id="job" value="ACC6REPORT005"/>
		<table width="100%" class="ui-widget ui-widget-content" border="0">
			<tr>
				<th align="left" class="acc67-header ui-widget-header" colspan="2"><b>${screenCode.ACC6REPORT005}</b></th>
			</tr>
			<tr>
				<td class="bold">จังหวัด : </td>
				<td>
					<c:if test="${userInfo.areaLevel =='3'}">
						<c:forEach var="data" items="${userInfo.listUserProvice}">
							${data.provinceName}
							<input type="hidden" name="provinceIdFilter" id="provinceIdFilter" value="${data.provinceId}">
						</c:forEach>
					</c:if>
					<c:if test="${userInfo.areaLevel=='1' || userInfo.areaLevel=='2'}">
						<select name="provinceIdFilter" id="provinceIdFilter">
							<option value="">เลือกทั้งหมด</option>
							<c:forEach var="data" items="${userInfo.listUserProvice}">
								<c:if test="${data.provinceId == provinceIdFilter}" var="provinceSeleted"/>
								<option value="${data.provinceId}" ${provinceSeleted?'selected':''}>${data.provinceName}</option>
							</c:forEach>
						</select>
					</c:if>
				</td>
			</tr>
			<tr>
				<td class="bold">ปีที่ออกรายงาน : </td>
				<td>
					<select name="budgetYearFilter" id="budgetYearFilter">
						<option value="">----- เลือก -----</option>
						<c:forEach items="${lsBudgetYear}" var="data">
							<c:if test="${budgetYearFilter == data.BUDGET_YEAR}" var="selected"/>
							<option value="${data.BUDGET_YEAR}" ${selected?'selected':''}>${data.BUDGET_YEAR}</option>
						</c:forEach>
					</select>
					<span id="$budgetYearFilter" class="red">*</span>
				</td>
			</tr>
			<tr>
				<td class="bold">วันที่ออกรายงาน : </td>
				<td>
					<input type="text" name="startDateFilter" id="startDateFilter" size="12" maxlength="10" onkeypress="return numberAndSlash(event);" onblur="dateFormat(this);" value="${startDateFilter}"/>
					ถึงวันที่
					<input type="text" name="endDateFilter" id="endDateFilter" size="12" maxlength="10" onkeypress="return numberAndSlash(event);" onblur="dateFormat(this);" value="${endDateFilter}"/>
					<span id="#endDateFilter" class="red">*</span>
				</td>
			</tr>
			<tr>
				<td class="bold">รหัสปีงบประมาณ : </td>
				<td>
					<select name="allocYearFilter" id="allocYearFilter">
						<option value="">----- เลือก -----</option>
						<c:forEach items="${lsBudgetYear}" var="data">
							<c:if test="${budgetYearFilter == data.BUDGET_YEAR}" var="selected"/>
							<option value="${data.BUDGET_YEAR}" ${selected?'selected':''}>${data.BUDGET_YEAR}</option>
						</c:forEach>
					</select>
				</td>
			</tr>
			<tr>
				<td align="center" colspan="2">
					<button type="button" name="btnSearch" id="btnSearch" class="acc67-button"> ค้นหาข้อมูล </button>
					<!-- <button type="button" name="btnExport" id="btnExport" class="acc67-button"> Download </button> -->
				</td>
			</tr>
		</table>
		</form>
	</body>
</html>